package yunhe.servlet;

import yunhe.entity.BoardInfo;
import yunhe.service.BoardServers;
import yunhe.service.impl.BoardServersImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@SuppressWarnings("serial")
public class GetBoard extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HttpSession session = req.getSession();
		BoardServers bd = new BoardServersImpl();
		List<BoardInfo> lb = bd.getBoard();
		session.setAttribute("boards", lb);
		String flag = req.getParameter("flag");
		if (flag.equals("EditBoard")) {
			resp.sendRedirect("editboard.jsp");
		}
		else if(flag.equals("AddNews")){
			resp.sendRedirect("addnews.jsp");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
